package cn.huhst.cas.weisiqian.pojo;

import cn.huhst.cas.weisiqian.util.JSON;

public class PostType {
	private String name;

	/**
	 * 帖子分类由大小写字母，数字，汉字，“.”，“ ”组成，长度不超过20
	 */
	public static String nameRegx = "^([a-zA-Z0-9]|[\\u4e00-\\u9fa5]|.| ){1,20}$";

	public static JSON checkNameFormat(String name, JSON json) {
		if (name==null || !name.matches(nameRegx)) {
			json.put("name", "帖子分类由大小写字母，数字，汉字，“.”，“ ”组成，长度不超过20");
		}
		return json;
	}

	public JSON checkFormat() {
		JSON json = new JSON();
		json = checkNameFormat(name, json);
		return json;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "PostType [name=" + name + "]";
	}

	public PostType(String name) {
		this.name = name;
	}

}
